package com.itheima.dao;

import com.itheima.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {

    //增
    @Insert("insert into `t_user` (`id`,`username`,`birthday`,`sex`,`address`) values (null,#{username},#{birthday},#{sex},#{address})" )
    int insert(User user);

    //删
    @Delete("delete from t_user where id = #{id}")
    int delete(Integer id);

    //改
    @Update("update t_user set `username`=#{username}, `birthday`=#{birthday}, `sex`=#{sex}, `address`=#{address} where id = #{id}")
    int update(User user);

    //查
    @Select("select * from t_user")
    List<User> selectAll();

    //通过ID查询
    @Select("select * from t_user where id=#{id}")
    User selectById(Integer id);

    //模糊查询
    @Select("select * from t_user where username like concat('%',#{username},'%')")
    List<User> selectLikeCondition(String username);
}
